<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/WEB-INF/template/globalTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:opif="http://www.opif.com/formathlon/jsf/tags">

    <ui:define name="title">#{msg['application.titre.gestion.domaine']}</ui:define>

    <ui:define name="ariane">
        <h:commandLink action="/faces/index.xhtml"
                       value="#{msg['application.titre.accueil']}"/>
        >
        #{msg['application.titre.gestion.domaine']}
    </ui:define>
    
    <ui:define name="content">
        <h:panelGroup styleClass="titre">Liste des domaines</h:panelGroup>
        <p:commandLink styleClass="lienAction lienCreer"
                       value="#{msg['application.creer']} un domaine"
                       action="#{gestDomaineBean.creer()}"
                       update="globalForm:popup"  />
        <p:dataTable value="#{gestDomaineBean.listDomaine}" var="domaine" id="dataTableListeDomaine"
                      emptyMessage="#{msg['application.emptyMessage']}">
            <p:column headerText="ID">
                <h:outputText value="#{domaine.id}"/>
            </p:column>
            <p:column headerText="Intitule">
                <h:outputText value="#{domaine.libelle}"/>
            </p:column>
            <p:column headerText="Description">
                <h:outputText value="#{domaine.description}"/>
            </p:column>
            <p:column headerText="Actions">
                <p:commandLink value="Modifier"
                               action="#{gestDomaineBean.modifier(domaine)}"
                               update="globalForm:popup"  />
                &nbsp;
                <p:commandLink action="#{gestDomaineBean.supprimer(domaine)}"
                               value="Supprimer"
                               update="globalForm:confirm"  />
            </p:column>
        </p:dataTable>
        <p:commandLink styleClass="lienAction lienCreer"
                       value="#{msg['application.creer']} un domaine"
                       action="#{gestDomaineBean.creer()}"
                       update="popup"  />

    </ui:define>

    
    <ui:define name="popup">
        <h:panelGrid columns="3">
            <h:outputLabel for="inputIntitule" value="Intitule"/>
            <p:inputText value="#{gestDomaineBean.domaine.libelle}" id="inputIntitule"
                          />
            <p:message for="inputIntitule"/>

            <h:outputLabel for="inputDescription" value="Description"/>
            <p:inputTextarea value="#{gestDomaineBean.domaine.description}"
                             id="inputDescription"/>
            <p:message for="inputDescription"/>
        </h:panelGrid>
        
        <opif:validationButton managedBean="#{gestDomaineBean}"
                               libelleValidation="Créer"
                               actionValidation="validerCreer"
                               onclick="popup.hide()"
                               update="dataTableListeDomaine messages"
                               rendered="#{gestDomaineBean.modeCreation}"/>
        
        <opif:validationButton managedBean="#{gestDomaineBean}"
                               libelleValidation="Modifier"
                               actionValidation="validerModifier"
                               onclick="popup.hide()"
                               update="dataTableListeDomaine messages"
                               rendered="#{!gestDomaineBean.modeCreation}"/>
    </ui:define>
</ui:composition>
